﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Orange.Lib.Effective
{
    public class LoggerEventArgs : EventArgs
    {
        public string Msg { get; private set; }
        public int Priority { get; private set; }

        public LoggerEventArgs(int Priority, string Msg)
        {
            this.Msg = Msg;
            this.Priority = Priority;
        }
    }

    public class Logger
    {
        //私有化构造器
        private Logger() { }

        //只读静态实例对象
        private static readonly Logger instance = null;

        //静态构造器
        static Logger()
        {
            instance = new Logger();
        }

        //静态属性
        public static Logger Singleton
        {
            get { return instance; }
        }

        //定义事件
        public event EventHandler<LoggerEventArgs> Log;

        public void AddMsg(int priority, string msg)
        {
            EventHandler<LoggerEventArgs> l = Log;
            if (l != null)
                l(this, new LoggerEventArgs(priority, msg));
        }
    }
}
